﻿#pragma once

#include <cstddef>
#include <functional>

#include "Common.hpp"
#include "Singleton.hpp"

ETERFREE_SPACE_BEGIN

class Termination final
{
public:
	using IDType = std::size_t;
	using Handler = std::function<void()>;

private:
	friend Termination& Singleton<Termination>::get();

private:
	static void handleExit();

	static void handleQuickExit();

	static void handleTerminate();

private:
	Termination() noexcept;

public:
	bool insertExitHandler(IDType _id, \
		const Handler& _handler) noexcept;

	bool insertExitHandler(IDType _id, \
		Handler&& _handler) noexcept;

	bool removeExitHandler(IDType _id) noexcept;

	bool insertQuickExitHandler(IDType _id, \
		const Handler& _handler) noexcept;

	bool insertQuickExitHandler(IDType _id, \
		Handler&& _handler) noexcept;

	bool removeQuickExitHandler(IDType _id) noexcept;

	bool insertTerminateHandler(IDType _id, \
		const Handler& _handler) noexcept;

	bool insertTerminateHandler(IDType _id, \
		Handler&& _handler) noexcept;

	bool removeTerminateHandler(IDType _id) noexcept;
};

ETERFREE_SPACE_END
